<?php
declare (strict_types=1);

namespace Plugin\Organization\Model;

use Hyperf\Database\Model\SoftDeletes;
use Mine\MineModel;

class RdOrganizeProjLine extends MineModel
{
    use SoftDeletes;
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_organize_proj_line';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'id', 'name', 'zone_id', 'sort', 'line_arr', 'line_style', 'status', 'created_by', 'updated_by', 'created_at', 'updated_at', 'deleted_at', 'remark', 'path'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'zone_id' => 'integer',
        'status' => 'integer',
        'sort' => 'integer',
        'line_arr' => 'array',
        'line_style' => 'array',
        'created_by' => 'integer',
        'updated_by' => 'integer',
        'deleted_at' => 'datetime',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];

    /**
     * 关联大区
     */
    public function zone()
    {
        return $this->belongsTo(RdOrganizeZone::class, 'zone_id');
    }

    /**
     * 关联工区
     */
    public function areas()
    {
        return $this->hasMany(RdOrganizeArea::class, 'proj_line_id');
    }
}